package demo1221.am;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/*
需求:计算做地铁花的金额
 步骤:从A站上车,到B站下车,计算是A到B站共需要的金额.
 规则:0-6站,共需要2元.
      7-10站,共需要3元.
      11-14站,共需要4元.
      大于等于15站,共需要5元.
 */
public class Demo_01 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        String[] arr = {"南岗", "桂庄路", "汽车西站", "振兴路", "蜀山西", "大蜀山",
                "天柱路", "科学大道", "十里庙", "西七里塘", "五里墩", "三里庵",
                "安农大", "三孝口", "四牌楼", "大东门"};
        for (String s : arr) {
            list.add(s);
        }
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入上车站点:");
        String sta = scan.next();
        System.out.println("请输入下车站点:");
        String end = scan.next();
        //根据值找到索引.
        int startIndex = list.indexOf(sta);
        int endIndex = list.indexOf(end);
        if (startIndex != -1 && endIndex != -1) {
            int count = Math.abs(startIndex - endIndex);
            int money;
            if (count >= 0 && count <= 6) {
                money =2;
            }else  if (count>=7&& count<=10){
                money=3;
            }else if (count>=11 && count<=14){
                money=4;
            }else {
                money=5;
            }
            System.out.println("你总共做"+count+"站,总共的地铁金额为:"+money);
        }


    }
}
